fix for rare failure on some motorola devices#28
fix for rare failure on some motorola devices#28SyedSaifAli wants to merge 2 commits intobrowserstack:masterfrom
Conversation
…ning rarely for some devices and clicking on i agree to continue with the existing flow
| public void test() throws Exception { | ||
| driver.get("https://www.google.com/ncr"); | ||
| try { | ||
| WebElement ele = driver.findElement(By.className("IKl7Q")); |
There was a problem hiding this comment.
Isn't these ids are generated by the framework at runtime and can change?
There was a problem hiding this comment.
yes, I have updated the code to find the element.
| WebElement ele = driver.findElement(By.className("IKl7Q")); | ||
| if(ele.isDisplayed()) { | ||
| ((JavascriptExecutor)driver).executeScript("arguments[0].scrollTo(0, arguments[0].scrollHeight)",ele); | ||
| driver.findElement(By.xpath("//*[@id='L2AGLb']/div")).click(); |
There was a problem hiding this comment.
these classnames and ids might change in the future with their deploys since they are generated for creating unique values from original classnames (to prevent collision)
Will require some other selectors.
| } | ||
| } | ||
| catch(Exception e){ | ||
| System.out.print(e); |
There was a problem hiding this comment.
Will this print the actual message or just tell the object type is of exception class?
There was a problem hiding this comment.
It will print this kind of message
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[text()='I agree']"}
| WebElement ele = driver.findElement(By.xpath("//div[text()='I agree']")); | ||
| if(ele.isDisplayed()){ | ||
| ((JavascriptExecutor)driver).executeScript("arguments[0].scrollIntoView()", ele); | ||
| Thread.sleep(5000); |
There was a problem hiding this comment.
We need this sleep because we are scrolling inside a modal to click on a div named I agree. and scrolling takes its own time for that element to be intractable.
If we do not add a sleep then getting following error while running click() command.
element click intercepted: Element <div class="jyfHyd" role="none">...</div> is not clickable at point (246, 524).
added try catch block for finding element of modal class which is opening rarely for some devices and clicking on i agree to continue with the existing flow